package com.lm.forkjoin.example;

import com.alibaba.excel.EasyExcel;
import com.lm.forkjoin.entry.UserData;

import java.util.ArrayList;
import java.util.List;

public class EasyExcelWriteExample {
    public static void main(String[] args) {
        String fileName = "simpleWrite.xlsx";

        // 数据准备
        List<UserData> data = new ArrayList<>();
        UserData userData = new UserData();
        userData.setId(1L);
        userData.setName("Alice");
        userData.setEmail("alice@example.com");
        userData.setAge(30);
        data.add(userData);
        userData = new UserData();
        userData.setId(2L);
        userData.setName("admin");
        userData.setEmail("admin@example.com");
        userData.setAge(50);
        data.add(userData);

        // 写入数据到 Excel 文件
        EasyExcel.write(fileName, UserData.class).sheet("用户信息").doWrite(data);
    }
}
